import * as Cesium from 'cesium';

/**
 * Viewer utility functions
 */

/**
 * Set view to a rectangle
 * @param {Cesium.Viewer} viewer - The Cesium viewer instance
 * @param {Object} rectangle - Rectangle bounds
 * @param {Number} rectangle.west - West longitude
 * @param {Number} rectangle.south - South latitude
 * @param {Number} rectangle.east - East longitude
 * @param {Number} rectangle.north - North latitude
 */
export function setViewRectangle(viewer, rectangle) {
  viewer.camera.setView({
    destination: Cesium.Rectangle.fromDegrees(
      rectangle.west,
      rectangle.south,
      rectangle.east,
      rectangle.north
    )
  });
}

/**
 * Set view to a specific position
 * @param {Cesium.Viewer} viewer - The Cesium viewer instance
 * @param {Object} options - Position options
 * @param {Number} options.lon - Longitude in degrees
 * @param {Number} options.lat - Latitude in degrees
 * @param {Number} options.height - Height in meters
 */
export function setViewPosition(viewer, options) {
  const { lon, lat, height = 100000 } = options;
  viewer.camera.setView({
    destination: Cesium.Cartesian3.fromDegrees(lon, lat, height)
  });
}

// 导出已改为命名导出，可删除默认导出对象